<?php
/**
 * | ---------------------------------------------------------------------------------------------------
 * | ProjectName: mvc
 * | ---------------------------------------------------------------------------------------------------
 * | Author：johnxu <fsyzxz@163.com>
 * | ---------------------------------------------------------------------------------------------------
 * | Home: https://www.xfjpeter.cn
 * | ---------------------------------------------------------------------------------------------------
 * | Data: 201907182019-07-18
 * | ---------------------------------------------------------------------------------------------------
 * | Desc:
 * | ---------------------------------------------------------------------------------------------------
 */

namespace app\common\validate;

use think\Validate;

class Admin extends Validate
{
    protected $rule = [
        'username' => 'require',
        'password' => 'require|regex:[\w_~,\.\?\@\#\$\%]{6,}',
        'nickname' => 'require',
        'email'    => 'require|email',
        'phone'    => 'require|mobile',
        'role_id'  => 'require',
    ];

    protected $message = [
        'username.require' => '账号不能为空',
        'username.unique'  => '账号已存在',
        'password.require' => '密码不能为空',
        'password.regex'   => '密码格式不正确',
        'nickname.require' => '请输入昵称',
        'email.require'    => '请输入电子邮箱',
        'email.email'      => '电子邮箱格式不正确',
        'phone.require'    => '请输入联系电话',
        'phone.mobile'     => '联系电话格式不正确',
        'role_id.require'  => '请选择所属角色',
    ];

    protected $scene = [
        'login' => ['username', 'password'],
        'add'   => ['username', 'password', 'nickname', 'email', 'phone', 'role_id'],
        'edit'  => ['username', 'password', 'nickname', 'email', 'phone', 'role_id'],
    ];
}